Unverified

Name

Add Categories to Pages

About

This snippet allows you to assign categories to WordPress pages, similar to how they are assigned to posts. This is useful when you want to organize your pages using categories and potentially display them in category-specific archives.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

1. Copy and paste the provided code into your theme's functions.php file or use a code snippets plugin. 2. Activate the snippet if using a plugin. 3. Once activated, go to your WordPress admin dashboard. 4. Navigate to Pages -> Add New/Edit. You will now see the category box in the sidebar. 5. You can now assign categories to your pages, and use them in queries or for organizing content in your theme.

Codevault

Jinu Varghese

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Snippet Source:

https://www.jinuvarghese.com/

History

Last modified:

18/09/2024

Important Note

This snippet has the following status:

Unverified

This snippet has not been verified, use with caution and at your own risk. See details provided by author in sidebar and click below to find out more.

Add Categories to Pages

 
                    
1// The below code is added to create a custom page taxonomies for the pages
2 
3function add_categories_to_pages() {
4 register_taxonomy_for_object_type('category', 'page');
5}
6add_action('init', 'add_categories_to_pages');

0

Related Snippets

Please see some snippets below related to this snippet..

General

AI Verified

0

Migrate BasePress -> BetterDocs: 4. Search Logs

Added: 11 months ago

Last Updated: 11 months ago

<p>Use these to migrate data from BasePress to BetterDocs, or clone them and customize to migrate to some other structure.</p> <p>Import all 4 snippets, then run them in order. This will handle docs,...

General

AI Verified

0

Better Breadcrumbs

Added: 9 months ago

Last Updated: 9 months ago

Two main customizations are made:1. Changing the label of the 'home' breadcrumb based on the current page.2. Modifying the URL linked to the 'home' breadcrumb depending on the page.

General

Unverified

0

DORIS

Added: 2 months ago

Last Updated: 2 months ago

D

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

General

Unverified

1

Convert to WebP

Added: 1 week ago

Last Updated: 1 day ago

This WordPress code snippet automatically converts uploaded images (JPEG, PNG, GIF) to WebP format during the upload process.

General

Unverified

0

Add Categories to Pages

Added: 1 day ago

Last Updated: 1 day ago

This snippet allows you to assign categories to WordPress pages, similar to how they are assigned to posts. This is useful when you want to organize your pages using categories and potentially display...